#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

class Solution {
public:
    int findNthDigit(int n) {
        if(n<=9){
            return n;
        }
        int i = 10;
        n = n-9;
        int len = 2;
        int index = 1;

        for(;n>0;++i){
            if(n>len*10){
                n  = n-len*10;
                i = i+9;
                ++index;
                if(index==pow(10,len-1)){
                    len += 1;
                    index=pow(10,len-2);
                }
            }
            else{
                n = n-len;
            }
        }
        string temp = to_string(i-1);
        int in = len+n-1;
        int A = temp[in]-'0';
        return  A;
    }
};

int main(){
    Solution S;
    int T = S.findNthDigit(32);
    return 0;
}